/* $Id: MapFrameMouseAdaptor.java 23 2009-03-31 23:37:36Z aaron.day $ */
package org.crazydays.gameplan.map.swing;


import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import org.crazydays.gameplan.Controller;

/**
 * MapMouseListener
 */
public class MapMouseListener
    extends MouseAdapter
{
    /** controller */
    protected Controller controller;

    /** menu */
    protected JMapContextMenu menu;

    /**
     * MapFrameMouseListener constructor.
     * 
     * @param controller Controller
     */
    public MapMouseListener(Controller controller)
    {
        this.controller = controller;
        this.menu = new JMapContextMenu(controller);
    }

    /**
     * Show context menu on right mouse click.
     * 
     * @param event Event
     * @see MouseAdapter#mouseReleased(MouseEvent)
     */
    public void mouseReleased(MouseEvent event)
    {
        // right button opens context menu
        if (event.getButton() == MouseEvent.BUTTON3) {
            menu.show(event.getComponent(), event.getX(), event.getY());
        }
    }
}
